package org.lvhengchang.schoolmanager.dao;

import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.lvhengchang.schoolmanager.bean.Admin;
import org.lvhengchang.schoolmanager.util.DataSourceTools;
/**
 * 管理员数据持久处理类
 * 
 * @author LvHengchang
 *
 */
public class AdminDao {
	

	    private DataSource dataSource = DataSourceTools.getDataSource();

	    private final static String LOGIN_SQL =
	            "select id, username, password, is_delete from t_admin where username = ? and password = ? and is_delete=0";

	    public Admin loginAdmin(String username, String password) throws SQLException {
	        QueryRunner queryRunner = new QueryRunner(dataSource);
	        Admin result = queryRunner.query(LOGIN_SQL, new BeanHandler<Admin>(Admin.class), username, password);
	        return result;
	    }
}
